package com.belizer.pay.config;


import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(WxPayProperties.class)
public class WxPayConfiguration {

    @Bean
    public Config config(WxPayProperties wxPayProperties) {
        return new RSAAutoCertificateConfig.Builder()
                .merchantId(wxPayProperties.getMerchantId())
                .privateKeyFromPath(wxPayProperties.getPrivateKeyPath())
                .merchantSerialNumber(wxPayProperties.getMerchantSerialNumber())
                .apiV3Key(wxPayProperties.getApiV3Key())
                .build();
    }

}
